package com.example.Film.reviews.website.controllers;

import com.example.Film.reviews.website.dao.Box_OfficeRepository;
import com.example.Film.reviews.website.dao.DirectorRepository;
import com.example.Film.reviews.website.dao.MovieRepository;
import com.example.Film.reviews.website.dao.PerformerRepository;
import com.example.Film.reviews.website.entities.Box_Office;
import com.example.Film.reviews.website.entities.Director;
import com.example.Film.reviews.website.entities.Movie;
import com.example.Film.reviews.website.entities.Performer;
import jdk.security.jarsigner.JarSignerException;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.GetMapping;

import java.util.Dictionary;
import java.util.List;

@Controller
public class HomeController {
    @Autowired
    MovieRepository movieRepository;

    @Autowired
    DirectorRepository directorRepository;

    @Autowired
    PerformerRepository performerRepository;

    @Autowired
    Box_OfficeRepository box_officeRepository;

    @GetMapping("/")
    public String displayHome(Model model) throws JarSignerException{
        List<Movie> movies = movieRepository.findAll();
        model.addAttribute("movies",movies);

        List<Director> directors = directorRepository.findAll();
        model.addAttribute("directors",directors);

        List<Performer> performers = performerRepository.findAll();
        model.addAttribute("performers",performers);

        List<Box_Office> box_offices = box_officeRepository.findAll();
        model.addAttribute("box_offices",box_offices);
        return "main/home";
    }
}
